package StudyCode.summary.Basic.numberformat;

import java.text.NumberFormat;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ThreeDecimal {
	public static void main(String[] args) {
		System.out.println("保留三位小数:");
		NumberFormat nf = NumberFormat.getNumberInstance();
		nf.setMinimumFractionDigits(3);
		nf.setMaximumFractionDigits(3);
		System.out.println(nf.format(12345.6789));
		System.out.println("保留两位小数:");
		nf.setMinimumFractionDigits(2);
		nf.setMaximumFractionDigits(1);
		System.out.println(nf.format(12345.6789));

	}
}
